<?php
namespace app\api\controller\wdsxh;
use app\common\controller\Api;
use app\admin\model\wdsxh\Banner as Model;
/**
 * 轮播图接口
 */
class Banner extends Base
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    public function index(){
        $page = isset($_SERVER['HTTP_PAGE']) ? $_SERVER['HTTP_PAGE'] : 1;
        $list=Model::where('pages',$page)
            ->where('status',1)
            ->order('weigh desc')
            ->field('id,title,image,pc_image,jump_type as nav_type,content')
            ->select();
        if($list){
            $list=collection($list)->toArray();
            foreach ($list as &$row){
                $row['image']=wdsxh_full_url($row['image']);
                $row['pc_image']=wdsxh_full_url($row['pc_image']);
                if($row['nav_type'] == 2){
                    $row['content']=json_decode($row['content'],true);
                }
            }
        }
        $this->success($list);
    }
}